home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / libs / info / general.h < prev    next >
C/C++ Source or Header  |  1995-11-28  |  3KB  |  100 lines

  1. /* general.h -- Some generally useful defines. */
  2. /* Changed for emx by Kai Uwe Rommel & Eberhard Mattes -- Nov 1995 */
  3.  
  4. /* This file is part of GNU Info, a program for reading online documentation
  5.    stored in Info format.
  6.  
  7.    Copyright (C) 1993 Free Software Foundation, Inc.
  8.  
  9.    This program is free software; you can redistribute it and/or modify
  10.    it under the terms of the GNU General Public License as published by
  11.    the Free Software Foundation; either version 2, or (at your option)
  12.    any later version.
  13.  
  14.    This program is distributed in the hope that it will be useful,
  15.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.    GNU General Public License for more details.
  18.  
  19.    You should have received a copy of the GNU General Public License
  20.    along with this program; if not, write to the Free Software
  21.    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22.  
  23.    Written by Brian Fox (bfox@ai.mit.edu). */
  24.  
  25. #if !defined (_GENERAL_H_)
  26. #define _GENERAL_H_
  27.  
  28. #ifdef EMX
  29. #define whitespace_or_newline(c) (whitespace (c) || (c == '\n') || (c == '\r'))
  30. #endif /* EMX */
  31.  
  32. extern void *xmalloc (), *xrealloc ();
  33.  
  34. #if defined (HAVE_UNISTD_H)
  35. #  include <unistd.h>
  36. #endif /* HAVE_UNISTD_H */
  37.  
  38. #if defined (HAVE_STRING_H)
  39. #  include <string.h>
  40. #else
  41. #  include <strings.h>
  42. #endif /* !HAVE_STRING_H */
  43.  
  44. #include "clib.h"
  45.  
  46. #define info_toupper(x) (islower (x) ? toupper (x) : x)
  47. #define info_tolower(x) (isupper (x) ? tolower (x) : x)
  48.  
  49. #if !defined (whitespace)
  50. #  define whitespace(c) ((c == ' ') || (c == '\t'))
  51. #endif /* !whitespace */
  52.  
  53. #if !defined (whitespace_or_newline)
  54. #  define whitespace_or_newline(c) (whitespace (c) || (c == '\n'))
  55. #endif /* !whitespace_or_newline */
  56.  
  57. #if !defined (__FUNCTION_DEF)
  58. #  define __FUNCTION_DEF
  59. typedef int Function ();
  60. typedef void VFunction ();
  61. typedef char *CFunction ();
  62. #endif /* _FUNCTION_DEF */
  63.  
  64. /* Add POINTER to the list of pointers found in ARRAY.  SLOTS is the number
  65.    of slots that have already been allocated.  INDEX is the index into the
  66.    array where POINTER should be added.  GROW is the number of slots to grow
  67.    ARRAY by, in the case that it needs growing.  TYPE is a cast of the type
  68.    of object stored in ARRAY (e.g., NODE_ENTRY *. */
  69. #define add_pointer_to_array(pointer, idx, array, slots, grow, type) \
  70.   do { \
  71.     if (idx + 2 >= slots) \
  72.       array = (type *)(xrealloc (array, (slots += grow) * sizeof (type))); \
  73.     array[idx++] = (type)pointer; \
  74.     array[idx] = (type)NULL; \
  75.   } while (0)
  76.  
  77. #define maybe_free(x) do { if (x) free (x); } while (0)
  78.  
  79. #if !defined (zero_mem) && defined (HAVE_MEMSET)
  80. #  define zero_mem(mem, length) memset (mem, 0, length)
  81. #endif /* !zero_mem && HAVE_MEMSET */
  82.  
  83. #if !defined (zero_mem) && defined (HAVE_BZERO)
  84. #  define zero_mem(mem, length) bzero (mem, length)
  85. #endif /* !zero_mem && HAVE_BZERO */
  86.  
  87. #if !defined (zero_mem)
  88. #  define zero_mem(mem, length) \
  89.   do {                    \
  90.     register int zi;        \
  91.     register unsigned char *place;    \
  92.                     \
  93.     place = (unsigned char *)mem;    \
  94.     for (zi = 0; zi < length; zi++)    \
  95.       place[zi] = 0;        \
  96.       } while (0)
  97. #endif /* !zero_mem */
  98.  
  99. #endif /* !_GENERAL_H_ */
  100.